package com.wthink.hzgj.copyFile

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.PopupWindow
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.wthink.hzgj.R
import com.wthink.hzgj.copyFile.viewmodel.CopyProgressDialogModel
import com.wthink.hzgj.databinding.DialogCopyProgressBinding
import com.wthink.hzgj.util.DpUtil
import com.wthink.hzgj.util.`interface`.ProgrossCallBack

class CopyProgressDialog {
    companion object {
        fun make(
            context: Context,
            container: ViewGroup,
            copyProgressDialogModel: CopyProgressDialogModel,
            activity: AppCompatActivity
        ): PopupWindow {
            val binding =
                DataBindingUtil.inflate<DialogCopyProgressBinding>(
                    LayoutInflater.from(context),
                    R.layout.dialog_copy_progress,
                    container,
                    false
                ).apply {
                    this.viewModel = copyProgressDialogModel
                    this.lifecycleOwner = activity
                }

            return PopupWindow(
                binding.root,
                DpUtil.dp2px(context, 370f),
                DpUtil.dp2px(context, 90f),
                true
            ).apply {
                isOutsideTouchable = false
                isFocusable = true
                animationStyle = R.style.popupwindow_anim_style

                copyProgressDialogModel.waitCopyProcess()

            }
        }
    }
}